#include <cstdio>
#include <queue>
using namespace std;

#define max(a,b) (a>b?a:b)

struct point {
	int x, y, dis;
	point():x(-1), y(-1), dis(0) { }
	point(int x, int y, int d):x(x), y(y), dis(d) { }
};

operator == (point &lhs, point &rhs) {
	return lhs.x==rhs.x && lhs.y==rhs.y;
}

int w, m, n;
point pm, pn;
bool book[10002][10002];

void get_pos(int n, point *p) {
	int t = n/w;
	p->x = t;
	if (t%2==0) {
		p->y = n%w;
	} else {
		p->y = w-(n%w)-1;
	}
}

int get_num(int x, int y) {
	if (x%2==0) {
		return x*w+y;
	} else {
		return x*w+(w-y-1);
	}
}

void bfs() {
	queue<point> s;
	s.push(pm);
	int max_x = max(pm.x, pn.x);
	book[pm.x][pm.y] = true;
	while (s.size() > 0) {
		point p = s.front(); s.pop();
		if (p == pn) {
			printf("%d\n", p.dis);
			break;
		}
		if (p.x-1>=0 && !book[p.x-1][p.y]) { //up
			book[p.x-1][p.y] = true;
			s.push(point(p.x-1, p.y, p.dis+1));
		}
		if (p.x+1<=max_x && !book[p.x+1][p.y]) { //down
			book[p.x+1][p.y] = true;
			s.push(point(p.x+1, p.y, p.dis+1));
		}
		if (p.y-1>=0 && !book[p.x][p.y-1]) { //left
			book[p.x][p.y-1] = true;
			s.push(point(p.x, p.y-1, p.dis+1));
		}
		if (p.y+1<w && !book[p.x][p.y+1]) { //right
			book[p.x][p.y+1] = true;
			s.push(point(p.x, p.y+1, p.dis+1));
		}
	}
}


int main() {
	scanf("%d%d%d", &w, &m, &n);
	m--; n--;
	get_pos(m, &pm);
	get_pos(n, &pn);
	bfs();
	return 0;
}
